SUBDIRS = icons normal_re conf pref test

bin_PROGRAMS = gpyp
gpyp_SOURCES = main.cpp options.cpp application.cpp conf.cpp \
yellowpage.cpp loader.cpp gtkcellrendererrelay.c peercast.cpp \
mainwindow.cpp panel.cpp channellist.cpp dialog.cpp \
menu.cpp widgets.cpp keybind.cpp notify.cpp \
command.cpp processview.cpp icon.cpp favorite.cpp \
misc.cpp environment.cpp strfuncs.cpp shellwords.cpp format.cpp search.cpp log.cpp \
sound.cpp screensaver.cpp growl.c
gpyp_LDADD = conf/libconf.a pref/libpref.a @X_PRE_LIBS@ \
@X11_LIBS@ @GTKMM_LIBS@ @GTHREAD_LIBS@ @GIO_LIBS@ \
@LIBNOTIFY_LIBS@ @BOOST_LDFLAGS@ @BOOST_DATE_TIME_LIB@ @BOOST_ASIO_LIB@ \
@ASIO_LIBS@ @LIBAO_LIBS@ @VORBIS_LIBS@ @MIGEMO_LIBS@ \
@X_LIBS@ @DBUS_GLIB_LIBS@ @BOOST_REGEX_LIB@ @ONIGURUMA_LIBS@ @GROWL_LDFLAGS@

noinst_HEADERS = exception.h options.h application.h conf.h \
yellowpage.h base64.h url.h loader.h gtkcellrendererrelay.h peercast.h \
mainwindow.h panel.h channellist.h dialog.h \
menu.h widgets.h keybind.h notify.h \
command.h processview.h icon.h favorite.h \
misc.h environment.h strfuncs.h shellwords.h format.h search.h log.h \
sound.h screensaver.h growl.h dbusservice.h gtkversion.h

defs = -DHAVE_BUILDINFO_H

EXTRA_DIST = paths.h.in dbus-object.xml.in dbus-defs.h.in

BUILT_SOURCES = paths.h buildinfo.h

if ENABLE_DBUS_SERVICE
  gpyp_SOURCES  += dbusservice.cpp
  BUILT_SOURCES += dbus-object.h dbus-defs.h
endif

if SVN
  BUILT_SOURCES += svn.h
  defs += -DHAVE_SVN_H
endif

CLEANFILES = $(BUILT_SOURCES) dbus-object.h dbus-object.xml dbus-defs.h

paths.h: paths.h.in Makefile
	sed -e 's,[@]localedir[@],$(localedir),g' \
	    -e 's,[@]prefix[@],$(prefix),g' \
	    -e 's,[@]bindir[@],$(bindir),g' \
	    -e 's,[@]pkgdatadir[@],$(pkgdatadir),g' \
	    -e 's,[@]pkglibdir[@],$(pkglibdir),g' \
	    -e 's,[@]pixmapsdir[@],$(pixmapsdir),g' \
	    -e 's,[@]pkgpixmapsdir[@],$(pkgpixmapsdir),g' \
	    -e 's,[@]pkgpixmaps_16dir[@],$(pkgpixmaps_16dir),g' \
	    -e 's,[@]pkgpixmaps_22dir[@],$(pkgpixmaps_22dir),g' \
	    -e 's,[@]pkgpixmaps_scalabledir[@],$(pkgpixmaps_scalabledir),g' \
	< $< > $@

svn.h: .svn
	echo '#define SVNVERSION "%s"' | sed -e "s,%s,`svnversion -n | sed 's/^.*://'`," > $@

buildinfo.h: $(gpyp_SOURCES) $(noinst_HEADERS)
	echo '#define AC_CONFIGURE_ARGS "$(ac_configure_args)"' > $@
	echo '#define BUILD_TIME '`date +%s` >> $@

dbus-object.h: dbus-object.xml Makefile
	dbus-binding-tool --mode=glib-server --prefix=gpyp_dbus $< > $@

dbus-object.xml dbus-defs.h: dbus-object.xml.in dbus-defs.h.in Makefile
	sed -e 's,[@]DBUS_NAME[@],org.gpyp3,g' \
	    -e 's,[@]DBUS_PATH[@],/org/gpyp3,g' \
	    -e 's,[@]DBUS_INTERFACE[@],org.gpyp3,g' < $@.in > $@

AM_CXXFLAGS = @GTKMM_CFLAGS@ @GTHREAD_CFLAGS@ @GIO_CFLAGS@ \
@LIBNOTIFY_CFLAGS@ @BOOST_CPPFLAGS@ \
@ASIO_CPPFLAGS@ @LIBAO_CFLAGS@ @VORBIS_CFLAGS@ @MIGEMO_CFLAGS@ \
@X_CFLAGS@ @DBUS_GLIB_CFLAGS@ @ONIGURUMA_CFLAGS@ @GROWL_CFLAGS@ $(defs)

AM_CFLAGS = $(AM_CXXFLAGS)
